import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["__id", "_status"],
    _excluded2 = ["__id", "_status"];
import intl from 'utils/intl';
import { CPAAS_FILE } from 'utils/config';
import { isTenantRoleLevel, getCurrentOrganizationId } from 'utils/utils';
import { CODE_UPPER } from 'utils/regExp';
var organizationId = getCurrentOrganizationId();
var isTenant = isTenantRoleLevel();
var apiPrefix = isTenant ? "".concat(CPAAS_FILE, "/v1/").concat(organizationId) : "".concat(CPAAS_FILE, "/v1"); // 表格ds

var tableDS = {
  autoQuery: true,
  selection: false,
  dataKey: 'content',
  queryFields: [!isTenant && {
    name: 'tenantLov',
    lovCode: 'CPFM.TENANT',
    type: 'object',
    label: intl.get('cpaas.common.model.common.tenantId').d('租户'),
    ignore: 'always',
    noCache: true
  }, !isTenant && {
    name: 'tenantId',
    type: 'string',
    bind: 'tenantLov.tenantId'
  }, {
    name: 'watermarkCode',
    type: 'object',
    label: intl.get('cfile.waterMark.model.waterMark.watermarkCode').d('编码')
  }, {
    name: 'description',
    label: intl.get('cfile.waterMark.model.waterMark.description').d('描述'),
    type: 'string'
  }, {
    name: 'watermarkType',
    type: 'string',
    label: intl.get('cfile.waterMark.model.waterMark.watermarkType').d('水印类型'),
    lookupCode: 'CFLE.WATERMARK_TYPE'
  }].filter(Boolean),
  fields: [!isTenant && {
    name: 'tenantId',
    label: intl.get('cfile.waterMark.model.waterMark.tenantId').d('租户'),
    type: 'string'
  }, {
    name: 'watermarkCode',
    type: 'object',
    label: intl.get('cfile.waterMark.model.waterMark.watermarkCode').d('编码')
  }, {
    name: 'description',
    label: intl.get('cfile.waterMark.model.waterMark.description').d('描述'),
    type: 'string'
  }, {
    name: 'watermarkTypeMeaning',
    type: 'string',
    label: intl.get('cfile.waterMark.model.waterMark.watermarkType').d('水印类型')
  }, {
    name: 'enabledFlag',
    type: 'number',
    label: intl.get('cfile.waterMark.model.waterMark.enabledFlag').d('启用标识')
  }].filter(Boolean),
  transport: {
    read: function read() {
      return {
        url: "".concat(apiPrefix, "/watermark-configs"),
        method: 'GET'
      };
    }
  }
};
var drawerDS = {
  autoQuery: false,
  autoQueryAfterSubmit: false,
  fields: [!isTenant && {
    name: 'tenantLov',
    lovCode: 'CPFM.TENANT',
    required: true,
    type: 'object',
    label: intl.get('cpaas.common.model.common.tenantId').d('租户'),
    ignore: 'always',
    noCache: true
  }, !isTenant && {
    name: 'tenantId',
    type: 'string',
    bind: 'tenantLov.tenantId'
  }, !isTenant && {
    name: 'tenantName',
    type: 'string',
    bind: 'tenantLov.tenantName'
  }, {
    name: 'watermarkCode',
    type: 'string',
    required: true,
    pattern: CODE_UPPER,
    label: intl.get('cfile.waterMark.model.waterMark.code').d('编码'),
    maxLength: 30,
    defaultValidationMessages: {
      patternMismatch: intl.get('cpaas.common.validation.codeUpper').d('全大写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”')
    }
  }, {
    name: 'description',
    type: 'string',
    label: intl.get('cfile.waterMark.model.waterMark.description').d('描述'),
    maxLength: 240
  }, {
    name: 'watermarkType',
    type: 'string',
    required: true,
    lookupCode: 'CFLE.WATERMARK_TYPE',
    label: intl.get('cfile.waterMark.model.waterMark.watermarkType').d('水印类型'),
    defaultValue: 'TEXT'
  }, {
    name: 'fillOpacity',
    type: 'number',
    required: true,
    label: intl.get('cfile.waterMark.model.waterMark.fillOpacity').d('透明度'),
    defaultValue: 0.5
  }, {
    name: 'color',
    type: 'string',
    label: intl.get('cfile.waterMark.model.waterMark.color').d('色彩'),
    defaultValue: '#ff0000',
    dynamicProps: function dynamicProps(_ref) {
      var record = _ref.record;
      return {
        required: record.get('watermarkType') !== 'IMAGE' && record.get('watermarkType') !== 'TILE_IMAGE'
      };
    }
  }, {
    name: 'fontSize',
    type: 'number',
    label: intl.get('cfile.waterMark.model.waterMark.fontSize').d('字体大小'),
    defaultValue: 60,
    dynamicProps: function dynamicProps(_ref2) {
      var record = _ref2.record;
      return {
        required: record.get('watermarkType') !== 'IMAGE' && record.get('watermarkType') !== 'TILE_IMAGE'
      };
    }
  }, {
    name: 'weight',
    type: 'number',
    label: intl.get('cfile.waterMark.model.waterMark.weight').d('图片宽度'),
    defaultValue: 200,
    dynamicProps: function dynamicProps(_ref3) {
      var record = _ref3.record;
      return {
        required: record.get('watermarkType') === 'IMAGE' || record.get('watermarkType') === 'TILE_IMAGE'
      };
    }
  }, {
    name: 'height',
    type: 'number',
    label: intl.get('cfile.waterMark.model.waterMark.height').d('图片高度'),
    defaultValue: 200,
    dynamicProps: function dynamicProps(_ref4) {
      var record = _ref4.record;
      return {
        required: record.get('watermarkType') === 'IMAGE' || record.get('watermarkType') === 'TILE_IMAGE'
      };
    }
  }, {
    name: 'xAxis',
    type: 'number',
    required: true,
    // label: intl.get('cfile.waterMark.model.waterMark.xAxis').d('横坐标'),
    defaultValue: 200,
    dynamicProps: function dynamicProps(_ref5) {
      var record = _ref5.record;
      return {
        label: record.get('watermarkType') === 'IMAGE' || record.get('watermarkType') === 'TEXT' ? intl.get('cfile.waterMark.model.waterMark.xAxis').d('横坐标') : intl.get('cfile.waterMark.model.waterMark.xMargin').d('横向间距')
      };
    }
  }, {
    name: 'yAxis',
    type: 'number',
    required: true,
    label: intl.get('cfile.waterMark.model.waterMark.yAxis').d('纵坐标'),
    defaultValue: 300,
    dynamicProps: function dynamicProps(_ref6) {
      var record = _ref6.record;
      return {
        label: record.get('watermarkType') === 'IMAGE' || record.get('watermarkType') === 'TEXT' ? intl.get('cfile.waterMark.model.waterMark.yAxis').d('纵坐标') : intl.get('cfile.waterMark.model.waterMark.yMargin').d('纵向间距')
      };
    }
  }, {
    name: 'align',
    type: 'number',
    required: true,
    label: intl.get('cfile.waterMark.model.waterMark.align').d('对齐方式'),
    defaultValue: 1
  }, {
    name: 'rotation',
    type: 'number',
    required: true,
    label: intl.get('cfile.waterMark.model.waterMark.rotation').d('倾斜角度'),
    defaultValue: 0
  }, {
    name: 'detail',
    type: 'string',
    required: true,
    maxLength: 480,
    label: intl.get('cfile.waterMark.model.waterMark.detail').d('水印内容'),
    help: intl.get('cfile.waterMark.model.waterMark.requireFont').d('水印内容包含中文时，需要指定字体文件')
  }, {
    name: 'fontUrl',
    type: 'string',
    maxLength: 480,
    label: intl.get('cfile.waterMark.model.waterMark.fontUrl').d('字体文件')
  }, {
    name: 'filename',
    type: 'string'
  }, {
    name: 'enabledFlag',
    type: 'boolean',
    required: true,
    label: intl.get('cfile.waterMark.model.waterMark.enabledFlag').d('启用标识'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 1
  }].filter(Boolean),
  transport: {
    read: function read(_ref7) {
      var data = _ref7.data;
      var watermarkId = data.watermarkId;
      return {
        url: "".concat(apiPrefix, "/watermark-configs/").concat(watermarkId),
        method: 'GET',
        data: {},
        params: {}
      };
    },
    create: function create(_ref8) {
      var data = _ref8.data;

      var _ref9 = Array.isArray(data) ? data[0] : {},
          __id = _ref9.__id,
          _status = _ref9._status,
          other = _objectWithoutProperties(_ref9, _excluded);

      return {
        url: "".concat(apiPrefix, "/watermark-configs"),
        method: 'POST',
        data: other
      };
    },
    update: function update(_ref10) {
      var data = _ref10.data;

      var _ref11 = Array.isArray(data) ? data[0] : {},
          __id = _ref11.__id,
          _status = _ref11._status,
          other = _objectWithoutProperties(_ref11, _excluded2);

      return {
        url: "".concat(apiPrefix, "/watermark-configs"),
        method: 'PUT',
        data: other
      };
    }
  }
};
export { tableDS, drawerDS };